#include <iostream>
using namespace std;

class MyDate {
public:
    MyDate() {
        year = 2000;
        month = 1;
        day = 1;
    }

    bool isPrime(int year) {
        if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            return true;
        }
        return false;
    }

    int getMaxsDay(int month) {
        int mons[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
        if(isPrime(year)) {
            mons[1] = 29;
        }
        return mons[month-1];
    }

    MyDate(int year, int month, int day) {
        this->year = year;
        if(month >= 1 && month <= 12) {
            this->month = month;
        }else {
            this->month = 1;
        }
        if(day >= 1 && day < getMaxsDay(this->month)) {
            this->day = day;
        } else {
            day = 1;
        }
    }

    int getYear() const {
        return year;
    }

    void setYear(int year) {
        MyDate::year = year;
    }

    int getMonth() const {
        return month;
    }

    void setMonth(int month) {
        MyDate::month = month;
    }

    int getDay() const {
        return day;
    }

    void setDay(int day) {
        MyDate::day = day;
    }

    friend ostream &operator<<(ostream &os, const MyDate &date) {
        os << date.year << " - " << date.month << " - " << date.day;
        return os;
    }

    bool operator==(MyDate date) {
        if(this->getYear() != date.getYear()) {
            return false;
        }
        if(this->getMonth() != date.getMonth()) {
            return false;
        }
        if(this->getDay() != date.getDay()) {
            return false;
        }
        return true;
    }

    MyDate & operator++() {
        day++;
        if(day > getMaxsDay(month)) {
            month++;
            day = 1;
            if(month > 12) {
                year++;
                month = 1;
            }
        }
        return *this;
    }

    MyDate & operator+=(int d) {
        day += d;
        return *this;
    }

    MyDate & operator-=(int d) {
        day -= d;
        return *this;
    }


private:
    int year;
    int month;
    int day;
};

int main() {
    MyDate date1;
    cout<<date1<<endl;
    MyDate date2(2019,12,9);
    cout<<date2<<endl;
    ++date2;
    cout<<date2<<endl;

    date2+=5;
    cout<<date2<<endl;
}